var crypto = require("crypto");
var commonkey = require("../../config/Common");

class common {
    sha(key) {
        const secret = commonkey.secret_key;
        const hash = crypto.createHmac('sha256', secret)//我们首先调用crypto模块中的createHmac()方法，通过sha256算法对明文进行哈希化。
            .update(key)
            .digest('hex');
        //console.log(hash);
        return hash;
    }

    MD5(key) {
        var md5 = crypto.createHash("md5");
        md5.update(key);
        var str = md5.digest('hex');
        var s = str.toUpperCase();  //32位大写   
        return s;
    }
}

module.exports = common;